#include <core/ipi.h>
#include <core/smp.h>
#include <core/atomic.h>
#include <core/schedule.h>
#include <core/spinlock.h>
#include <core/task.h>
#include <arch/cpu.h>
#include <arch/gic_v2.h>
#include <stdlib/stdint.h>

#define ENABLE_SMP_TRANSER_LOG 0

atomic_t   cores = ATOMIC_INIT(1);
spinlock_t lock  = SPINLOCK_INIT_LOCKED;

void smp_secondary_cores_up(void)
{
    atomic_add(&cores, 1);

    while (spin_is_locked(&lock)) {
    	;
    }

}

void smp_active_secondary_cores(void)
{
    spin_unlock(&lock);
}

unsigned int smp_current_cores(void)
{
    return atomic_load(&cores);
}
